package com.ship.boats.business;

import cn.hutool.json.JSONUtil;
import com.ship.boats.domain.vo.BoatsArchivesInfo;
import com.ship.boats.service.*;
import com.ship.common.core.web.domain.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <b>ShipBaochuanBusiness</b>
 *
 * @description: ShipBaochuanBusiness <br>
 * @date: 2024/3/21 14:00 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "宝船网对外模块")
@RestController
public class ShipBaochuanBusiness {
    private static final Logger logger = LoggerFactory.getLogger(ShipBaochuanBusiness.class);

    @Autowired
    private SpBoatsPscInspectService spBoatsPscInspectService;

    @Autowired
    private BoatsArchivesService boatsArchivesService;

    @Autowired
    private SpBoatsAisMessageService spBoatsAisMessageService;

    @Autowired
    private BoatsCanalAccessService boatsCanalAccessService;

    @Autowired
    private BoatsVoyageMessageService boatsVoyageMessageService;

    @Autowired
    private BoatsWeatherService boatsWeatherService;

    @Autowired
    private BoatsEventMessageService boatsEventMessageService;

    @ApiOperation("查询宝船网SPC数据")
    @PostMapping("/query/create_psc_inspect")
    public void queryCreatePSCInspect(){
        spBoatsPscInspectService.queryCreatePSCInspect();
    }


    @ApiOperation("同步船舶档案信息")
    @PostMapping("/get/boats_archives")
    public JsonResult getBoatsArchives(@RequestBody List<BoatsArchivesInfo> archivesList){
        boolean status = boatsArchivesService.getBoatsArchives(archivesList);
        return JsonResult.success(status);
    }


    @ApiOperation("同步船舶挂靠岸信息")
    @PostMapping("/get/boatsDockWith")
    public JsonResult getBoatsDockWith(){
        boolean status = boatsArchivesService.getBoatsDockWith();
        return JsonResult.success(status);
    }

    @ApiOperation("同步姊妹船信息")
    @GetMapping("/get/boatsSister")
    public void getBoatsSister(){
        boatsArchivesService.getBoatsSister();
    }


    @ApiOperation("获取AIS信息")
    @PostMapping("/get/AIS_message")
    public void getAISMessage(){
        spBoatsAisMessageService.addBoatsAirMessage();
    }

//    @ApiOperation("查询吃水信息")
//    @GetMapping("/query/boatsDraught")
//    public void queryBoatsDraught(String mmsi,String time){
//        boatsArchivesService.queryBoatsDraught(mmsi,time);
//    }

    @ApiOperation("同步运河通行量")
    @PostMapping("/get/canalAccess/list")
    public void getCanalAccessList(){
        boatsCanalAccessService.addCanalAccessList();
    }

    @ApiOperation("同步航次信息")
    @PostMapping("/query/boatsVoyage/list")
    public void getBoatsVoyageMessage() throws ParseException {
        boatsVoyageMessageService.getBoatsVoyageMessage(null,null);
    }

    @ApiOperation("同步历史航次信息")
    @PostMapping("/query/boatsVoyage/list/all")
    public void getBoatsVoyageMessageAll(@RequestParam String startDate,@RequestParam String endDate) throws ParseException {
        boatsVoyageMessageService.getBoatsVoyageMessage(startDate,endDate);
    }

    @ApiOperation("同步天气列表")
    @PostMapping("/query/boatsWeather")
    public void getBoatsWeather(){
        boatsWeatherService.getBoatsWeather();
    }

    @ApiOperation("同步事件信息")
    @PostMapping("/query/boatsEventMessage")
    public void getBoatsEventMessage(){
        boatsEventMessageService.getBoatsEventMessage();
    }
}
